package com.teemor.common.bean.utils.tools;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * @Function com.shop.common.util.DateTool.
 * @Description //TODO 时间格式化工具
 *
 * @param: null
 * @return
 * @errorCode //TODO
 *
 * @Author zhoulk
 * @Date 2019/3/29 12:09
 *
 **/
public class DateTool {
    public static String BASE_FORMAT="yyyy-MM-dd HH:mm:ss:SSS";

    public static Date newNowDate(){
        return new Date();
    }

    public static Date afterDate(Date date,int day){
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        int day1 = c.get(Calendar.DATE);
        c.set(Calendar.DATE, day1 + day);
        return c.getTime();
    }

    public static Date beforDate(Date date,int day){
        Calendar c = Calendar.getInstance();
        c.setTime(date);
        int day1 = c.get(Calendar.DATE);
        c.set(Calendar.DATE, day1 - day);
        return c.getTime();
    }

    public static String newFormatDate(String fomat){
        SimpleDateFormat dateFormat=new SimpleDateFormat(fomat);
        Date date=new Date();
        return dateFormat.format(date);
    }
    public static String newBaseFormatDate(){
        return newFormatDate(BASE_FORMAT);
    }

    public static Date paresDate(Long time){
        return new Date(time);
    }

}
